// Author: Ivan Kazmenko (gassa@mail.ru)
module solution;
import std.algorithm;
import std.math;
import std.stdio;

immutable real epsilon = 1E-9;

struct Point
{
	real x;
	real y;
}

real dist () (const auto ref Point a, const auto ref Point b)
{
	return sqrt ((a.x - b.x) ^^ 2 + 0.0L + (a.y - b.y) ^^ 2);
}

real heron () (const auto ref Point a,
    const auto ref Point b, const auto ref Point c)
{
	auto u = dist (a, b);
	auto v = dist (b, c);
	auto w = dist (c, a);
	auto p = (u + v + w) * 0.5L;
	return sqrt (p * (p - u) * (p - v) * (p - w));
}

void main ()
{
	int tests;
	readf (" %s", &tests);
	foreach (test; 0..tests)
	{
		Point a, b, c, p, q;
		readf (" %s %s", &a.x, &a.y);
		readf (" %s %s", &b.x, &b.y);
		readf (" %s %s", &c.x, &c.y);
		readf (" %s %s", &p.x, &p.y);
		readf (" %s %s", &q.x, &q.y);
		real area = heron (a, b, c) * 2.0;
		real base = max (dist (a, b), dist (b, c), dist (c, a));
		real gate = dist (p, q);
		writeln ((area / base <= gate + epsilon) ? "YES" : "NO");
	}
}
